import path from 'node:path';

import cors from 'cors';
import express from 'express';
import history from 'connect-history-api-fallback';

// import $config from '../jjb.config.json' assert { type: 'json' };
import $config from '../jjb.config.json' with { type: 'json' };

const app = express();
const port = $config.server?.proxyPort || 8080;
const host = $config.server?.proxyHost || '127.0.0.1';

app.use(cors('*'));

/**
 * 单页面应用需要的历史记录模块
 */
app.use(history());

/**
 * 输出静态资源
 */
app.use(express.static(path.resolve('dist')));

/**
 * 监听端口
 */
app.listen(port, host, () => console.log(`Your application is running here: http://${host}:${port}`));
